<%@ page contentType="text/html; charset=utf-8"%>
<%@ include file="../../../common/include.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<jsp:include page="../../../common/head.jsp">
			 <jsp:param name="_useTab" value="true"/>
			 <jsp:param name="_useCalendar" value="true"/>
		</jsp:include>

		<title>费用核销</title>
		<style type="text/css">
			.feeTol{font-weight: bold;color:#000;}
			.feeTitle{background-color: #A2C0E1;}
		</style>
		<script language="JavaScript">
			function saveData(){
				var objarr = new Array(
					["feeReport.feeReportCode","编号","notEmpty",""]
				);
				if(xj.CheckAll(objarr))
				{
					if(confirm("确认保存？"))
					{
						document.getElementById("form1").submit();
					}
				}
			}
			//费用核销
			function writtenOffData(targetId,feeTypeId)
			{
				var a = ModalWindow("jump.do?path=updateDetailFeeWrittenOff.do&feeReportId=${feeReport.feeReportId}&edit=${edit}&targetId="+targetId+"&feeTypeId="+feeTypeId,1000,700);
				if(a!=null)
					window.location.href = "showExamineFeeWrittenOff.do?feeReportId=${feeReport.feeReportId}";
			}
			//统计生效
			function updateData(feeId)
			{
				var objarr = new Array(
					["feeReport.otherFeeRemark","其他费用说明","max","String:500"],
					["feeReport.writtenOffReportRemark","备注","max","String:500"]
				);
				if(xj.CheckAll(objarr))
				{
					if(confirm("确认统计生效？"))
					{
						document.form1.submit();
					}
				}
			}
			$(document).ready(function()
			{
				if('${param.showTab}'=='detail')
					xjTabs.initTab({firstTabSeq:1});
				else
					xjTabs.initTab();
			});
			//返回
			function goBack()
			{
				window.location.href="listFeeWrittenOff.do";
			}
			
			//查看费用明细
			function showData(feeId)
			{
				ModalWindow("jump.do?path=showFeeDetail.do&feeId="+feeId,800,600);
			}
			//加调项目
			function addData()
			{
				var a = ModalWindow("jump.do?path=addFeeDetail.do&from=writtenOff&feeReportId=${feeReport.feeReportId}",1000,600);
				if(a!=null)
					window.location.href = "showExamineFeeWrittenOff.do?feeReportId=${feeReport.feeReportId}";
			}
			//修改费用信息
			function editData(feeId)
			{
				var a = ModalWindow("jump.do?path=updateFeeDetail.do&from=writtenOff&feeId="+feeId,1000,600);
				if(a!=null)
					window.location.href = "showExamineFeeWrittenOff.do?feeReportId=${feeReport.feeReportId}&showTab=detail";
			}
			//移除费用信息
			function deleteData(feeId)
			{
				if(confirm("确认从当前上报信息中移除该条费用数据？"))
				{
					var a  = ModalWindow("jump.do?path=removeFeeDetail.do&from=writtenOff&feeId="+feeId,640,480);
					if(a!=null)
						window.location.href = "showExamineFeeWrittenOff.do?feeReportId=${feeReport.feeReportId}&showTab=detail";
				}
			}
		</script>
	</head>
	<body>
	<form action="updateFeeWrittenOff.do" name="form1" id="form1" method="post">
	<div id="body_div">
	<w:ShowTitle name="费用核销" useSubmitKey="false">
	<w:TitleButton funcName="统计生效" onClickFunction="updateData()" urlImg="${ctx}/images/main/update.png" hideCondition="${edit eq 'false'}"/>
	<w:TitleButton funcName="加调项目" onClickFunction="addData()" urlImg="${ctx}/images/main/add.png" hideCondition="${edit eq 'false'}"/>
	<w:TitleButton funcName="返回" onClickFunction="goBack()" urlImg="${ctx}/images/main/back.png"/>
	</w:ShowTitle>
	<div id="body_content">
		<div class="Sliding_tab">
			<ul>
				<li></li><li><span class="tabsLink" id="setTab0" link="#">审核费用</span></li><li></li>
				<li></li><li><span class="tabsLink" id="setTab1" link="#">费用明细</span></li><li></li>
			</ul>
		</div>
		<div id="content0" class="tabContent">
		<table width="100%">
			<tr>
              <td width="80" class="right_align">编号</td>
              <td class="left_align">
				<input type="hidden" name="feeReport.feeReportId" value="${feeReport.feeReportId}"/>
				${feeReport.feeReportCode}
			  </td>
              <td width="80" class="right_align">地区</td>
              <td class="left_align">
				${feeReport.areaName}
			  </td>
              <td class="right_align"><span class="left_align">事业部</span></td>
              <td class="left_align">
				${feeReport.areaDeptName}
			  </td>
              <td width="80" class="right_align">核销月份</td>
              <td class="left_align">
              		${feeReport.feeReportYear}${feeReport.feeReportMonth }
              		
              </td>
              <td width="80" class="right_align">终止日期</td>
              <td class="left_align">
              	<fmt:formatDate value='${feeReport.endDate}' pattern="yyyy-MM-dd" />
              </td>
              <td width="80" class="right_align">经手人</td>
              <td class="left_align">
              	${feeReport.createUserName }
              </td>
			 </tr>
          </table>
          <table>
	          <tr>
	              <td width="120" rowspan="4" class='feeTitle'>项目</td>
	              <td width="60" class='feeTitle'>一级</td>
	              ${tdTitle1}
	          </tr>
	          <tr>
	           	<td class='feeTitle'>二级</td>
	          	${tdTitle2}
	          </tr>
	          <tr>
	          	<td class='feeTitle'>三级</td>
	          	${tdTitle3}
	          </tr>
	          <tr>
	          	<td class='feeTitle'></td>
	          	${tdTitle4}
	          </tr>
	          ${listHtml}
          </table>
          <table width="100%">
					<tr>
					  <td width="80" class="right_align">凭证起始号</td>
		              <td class="left_align">
						${feeReport.certificateNoStart}
					  </td>
					  <td width="80" class="right_align">凭证终止号</td>
		              <td class="left_align">
						${feeReport.certificateNoEnd}
					  </td>
					  <td width="80" class="right_align">票据金额</td>
		              <td class="left_align">
						${feeReport.billAmountTol}
					  </td>
					  <td width="80" class="right_align">票据张数</td>
		              <td class="left_align">
						${feeReport.billCountTol}
					  </td>
					  <td width="80" class="right_align">凭证金额</td>
		              <td class="left_align">
						${feeReport.certificateAmountTol}
					  </td>
					  <td width="80" class="right_align">凭证张数</td>
		              <td class="left_align">
						${feeReport.certificateCountTol}
					  </td>
					</tr>
					<tr>
					  <td class="right_align">其他费用说明</td>
		              <td class="left_align" colspan="5">
						<textarea name="feeReport.otherFeeRemark" cols="50" rows="3">${feeReport.otherFeeRemark}</textarea>
					  </td>
					  <td class="right_align">备注</td>
		              <td class="left_align" colspan="5">
						<textarea name="feeReport.writtenOffReportRemark" cols="50" rows="3">${feeReport.writtenOffReportRemark}</textarea>
					  </td>
					  
					</tr>
		          </table>
          </div>
				<table width="100%" id="content1" class="tabContent listTable">
					<tr>
                        <td class="td_title">发生对象</td>
                        <td class="td_title">对象名称</td>
                        <td class="td_title">费用类别</td>
                        <td width="80" class="td_title">登记日期</td>
                        <td width="80" class="td_title">财务主管</td>
                        <td width="80" class="td_title">金额</td>
                        <td width="80" class="td_title">核销金额</td>
                        <td width="80" class="td_title">费用日期</td>
                        <td width="100" class="td_title">操作</td>
                      </tr>
					<c:forEach items="${writtenOffList}" var="obj">
						<tr>
							<td class="left_align">${obj.feeTarget}</td>
							<td class="left_align">${obj.targetName}</td>
							<td class="left_align">${obj.feeTypeName}</td>
							<td class="left_align"><fmt:formatDate value='${obj.createDate}' pattern="yyyy-MM-dd" /></td>
							<td class="left_align">${obj.financeSupervisorName}</td>
							<td class="left_align">${obj.billAmount+obj.certificateAmount}</td>
							<td class="left_align">${obj.billAmountWrittenOff+obj.certificateAmountWrittenOff}</td>
							<td class="left_align"><fmt:formatDate value='${obj.feeDate}' pattern="yyyy-MM-dd" /></td>
							<td>
								<c:if test="${obj.isAddState eq '加调'}">
								<a href="#" onclick="javascript:editData('${obj.feeId}')">修改</a>
								<a href="#" onclick="javascript:deleteData('${obj.feeId}')">移除</a>
								</c:if>
								<a href="#" onclick="javascript:showData('${obj.feeId}')">查看</a>
							</td>
						</tr>
					</c:forEach>
				</table>
			</div>
		</div>	
		</form>
	</body>
</html>